package com.example.exception;

import com.example.entity.CarEntity;

import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.ext.ExceptionMapper;
import javax.ws.rs.ext.Provider;
import java.math.BigDecimal;
@Provider
public class ServiceExceptionHandler implements ExceptionMapper<ServiceException> {

    @Override
    public Response toResponse(ServiceException exception) {
        CarEntity carEntity = new CarEntity();
        //carEntity.setPrice(BigDecimal.valueOf(123));
        return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(carEntity).type(MediaType.APPLICATION_JSON).build();
    }
}
